package structuralPattern.singletonPattern;
// 双重检查锁模式、线程安全、防止序列化和反射破解
public class DoubleCheckLockPattern {
    private static DoubleCheckLockPattern instance;
    private DoubleCheckLockPattern(){
        if (null != instance){
            throw new RuntimeException("不允许反射");
        }
    }
    public static DoubleCheckLockPattern getInstance(){
        if (null == instance){
            DoubleCheckLockPattern doubleCheckLockPattern;
            synchronized (DoubleCheckLockPattern.class){
                if (null == doubleCheckLockPattern){
                    synchronized (DoubleCheckLockPattern.class){
                        instance = doubleCheckLockPattern;
                    }
                }
            }
        }
        return instance;
    }
}
